package com.clouddisk.common.core.domain.entity;

import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.qiwenshare.common.util.DateUtil;
import com.qiwenshare.ufop.operation.upload.domain.UploadFileResult;
import lombok.Data;

/**
 * 文件实体类
 *
 * @author ZJH
 */
@Data

@TableName("file")
public class FileBean {


    @TableId(value = "file_id")
    private String fileId;

    /**
     * 文件url
     */

    private String fileUrl;

    /**
     * 文件大小
     */
    private Long fileSize;

    /**
     * 文件状态(0-失效，1-生效)
     */
    private Integer fileStatus;

    /**
     * 存储类型
     */
    private Integer storageType;

    /**
     * md5唯一标识
     */
    private String identifier;

    /**
     * 创建时间
     */
    private String createTime;

    /**
     * 创建用户id
     */
    private Long createUserId;

    /**
     * 修改时间
     */
    private String modifyTime;

    /**
     * 修改用户id
     */
    private Long modifyUserId;

    /**
     * 文件所属部门
     */
    public String fileDeptName;

    public FileBean(){

    }

    public FileBean(UploadFileResult uploadFileResult,String fileDeptName) {
        this.fileId = IdUtil.getSnowflakeNextIdStr();
        this.fileUrl = uploadFileResult.getFileUrl();
        this.fileSize = uploadFileResult.getFileSize();
        this.fileStatus = 1;
        this.storageType = uploadFileResult.getStorageType().getCode();
        this.identifier = uploadFileResult.getIdentifier();
        this.createTime = DateUtil.getCurrentTime();
        this.fileDeptName = fileDeptName;
    }

    public FileBean(String fileUrl, Long fileSize, Integer storageType, String identifier, Long userId,String fileDeptName) {
        this.fileId = IdUtil.getSnowflakeNextIdStr();
        this.fileUrl = fileUrl;
        this.fileSize = fileSize;
        this.fileStatus = 1;
        this.storageType = storageType;
        this.identifier = identifier;
        this.createTime = DateUtil.getCurrentTime();
        this.createUserId = userId;
        this.fileDeptName = fileDeptName;
    }

}
